<?php
// $Id: capt.php,v 1.4 2005/04/20 02:46:38 roflo1 Exp $

/* connect to database */
require 'connectdb.php';

$f=mysql_query("SELECT * FROM " . $CFG_TABLE[history] . " WHERE ((replaced > '') OR (curPiece = 'pawn' AND toCol <> fromCol AND replaced IS NULL)) AND gameID =  '".$_SESSION['gameID']."' ORDER BY curColor DESC, replaced DESC");

$c=0;
$d=0;
echo('var captPieces = [[');
while($row=mysql_fetch_array($f, MYSQL_ASSOC)){
	if(ereg("white",$row['curColor']))
		$c++;
	if($c==1){
		echo"], [";
		$d = 0;
	}
	if($d > 0)
		echo ', ';
	$d++;
	if($row['replaced'] == '')
		$row['replaced'] = 'pawn';

	echo "'".$row['replaced']."'";

} // End while

echo "]];\n";

?>
